﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Sharp.Infrastructure;
using Sharp.Portal.ExtNet.Provider;
using Sharp.Portal.Mvc.List;
using Sharp.Portal.Other;

namespace Sharp.Portal.ExtNet
{
    /// <summary>
    /// ListPage 实现
    /// </summary>
    public partial class ExtSharpList : SharpList
    {
        /// <summary>
        /// ListPage 实现
        /// </summary>
        public ExtSharpList() : base()
        {
            Simple = true;
            Listeners = new Dictionary<string, string>();
        }
        /// <summary>
        /// 初始化标题
        /// </summary>
        protected override void InitTitle()
        {
            HideTitle = true;
            base.InitTitle();
        }
        /// <summary>
        /// 初始化完成
        /// </summary>
        public override void InitComplete()
        {
            //this.ListControlId = this.ListControlId + this.GetType().FullName.Md5();
            this.Listeners.Add("ItemDblClick", "App.Grid.OnModuleGridItemDblClick");
            this.Listeners.Add("ItemClick", "App.Grid.DoGridItemClick");
            this.Listeners.Add("ColumnHide", "App.Grid.HideColumn");
            this.Listeners.Add("ColumnResize", "App.Grid.ResizeColumn");
            this.Listeners.Add("ColumnMove", "App.Grid.MoveColumn");
            this.Listeners.Add("ColumnShow", "App.Grid.ShowColumn");
            this.Listeners.Add("SortChange", "App.Grid.ChangeSort");

            if (IsMobileDevice())
            {
                this.Feature = this.Feature & ~Other.ListFeature.MultiSelect;
                this.Feature = this.Feature & ~Other.ListFeature.RowNumber;
            }

            base.InitComplete();
        }
        /// <summary>
        /// 侦听器
        /// </summary>
        public Dictionary<string, string> Listeners { get; set; }

        /// <summary>
        /// 自动刷新，单位秒
        /// 当值大于0时，激发自动刷新
        /// </summary>
        public int AutoRefresh { get; set; }

        /// <summary>
        /// 简单模式
        /// </summary>
        public bool Simple { get; set; }
        /// <summary>
        /// 初始化适配器
        /// </summary>
        public override void InitProvider()
        {
            if (this.Provider == null)
                this.Provider = new ListPage();

        }
    }
}